import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 98152
 * Date: 2024-07-02
 * Time: 17:32
 */
public class TestDemo1 {
    public static void main(String[] args) {
        int[] arr = {1,2,3,4,5,6,7,8,9};
        int count1 = 0;//记录数组中奇数的个数
        int count2 = 0;//记录数组中偶数的个数
        for (int i = 0; i < arr.length; i++) {
            if(arr[i]%2 != 0){
                count1++;
            }else {
                count2++;
            }
        }
        int[] arr1 = new int[count1];//奇数数组
        int[] arr2 = new int[count2];//偶数数组
        int n1 = 0;//奇数数组下标
        int n2 = 0;//偶数数组下标
        for (int i = 0; i < arr.length; i++) {
            if(arr[i]%2 != 0){
                arr1[n1++] = arr[i];
            }else {
                arr2[n2++] = arr[i];
            }
        }
        Arrays.sort(arr1);
        Arrays.sort(arr2);
        System.out.println(Arrays.toString(arr1));
        System.out.println(Arrays.toString(arr2));
    }
}
